<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>请假记录</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">

	<link rel="stylesheet" href="css/demo.css">
	<link rel="stylesheet" href="css/font-awesome.css">
	<link rel="stylesheet" href="css/sky-mega-menu.css">

	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="css/bootstrap-theme.css">




</head>
<body class="bg-blue">
<div class="body">
	<!-- mega menu -->
    <ul class="sky-mega-menu sky-mega-menu-anim-scale sky-mega-menu-response-to-icons">
        <!-- about -->
        <li>
            <a href="#"><i class="fa fa-lemon-o"></i>考勤管理系统</a>
        </li>

        <li class="right">
            <a href="/daka"><i class="fa fa-tags"></i>今日打卡</a>

        </li>
        <!-- contacts -->
        <li class="right">
            <a href="#_"><i class="fa fa-phone"></i>事项管理</a>
            <div class="grid-container3">
                <ul>
                    <li><a href="/leave"><i class="fa fa-briefcase"></i>请假</a></li>
                    <li><a href="/out"><i class="fa fa-briefcase"></i>外出</a></li>
                    <li><a href="/comleave"><i class="fa fa-briefcase"></i>调休</a></li>
                </ul>
            </div>
        </li>
        <!--/ contacts -->

        <!-- drop me a line -->
        <li aria-haspopup="true" class="right">
            <a href="#_"><i class="fa fa-tasks"></i>员工信息</a>
            <div class="grid-container3">
                <ul>
                    <li><a href="/info"><i class="fa fa-user"></i>个人信息</a></li>
                    <li><a href="/cal"><i class="fa fa-print"></i>打卡记录</a></li>
                    <li><a href="/logout"><i class="fa fa-chevron-circle-right"></i>注销</a></li>
                </ul>
            </div>

    </ul>
    <div class="col-lg-12"><br><br></div>
	<!--/ mega menu -->
    <div class="col-lg-4">
        <ul class="nav nav-pills nav-stacked" style="width:200px;text-align:center">

            <li class="active"><a href="/leave">请假申请</a></li>
            <li class="active"><a href="/leave2">我的请假</a></li>
        </ul>
    </div>

    <div style="margin: 20px" class="col-lg-4">


            <div class="form-group">
                <label >开始时间</label>
                <input type="date" class="form-control  "  placeholder="开始时间" id = "startDate">
                <input type="time" class="form-control  "  placeholder="开始时间" id = "startTime">
            </div>
            <div class="form-group">
                <label >结束时间</label>
                <input type="date"  class="form-control "  placeholder="结束时间" id = "endDate">
                <input type="time" class="form-control  "  placeholder="结束时间" id = "endTime">
            </div>
            <div class="form-group">
                <label >请假理由</label>
                <textarea class="form-control" rows="3"placeholder="文体不限，诗歌除外 不多于200字" id="reason"></textarea>
            </div>
            <div class="form-group ">
                <label >请假类型</label>
                <select class="form-control pull-left" id = "selection">
                    <option>婚假</option>
                    <option>病假</option>
                    <option>探亲假</option>
                    <option>产假</option>
                    <option>事假</option>
                    <option>年假</option>
                    <option>其他</option>
                </select>
            </div>

            <br><br><br>
            <button  class="btn btn-success pull-right" onclick="submit();">确认</button>

    </div>
</div>


</body>


<script src="js/moment-with-locales.js"></script>
<script type="text/javascript" src="https://lib.baomitu.com/jquery/3.3.1/jquery.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" ></script>
<script src="js/bootstrap.js"></script>
<script src="js/leave.js"></script>
<script src="layer/layer.js"></script>
<script>
    function submit(){

        var startDate = document.getElementById("startDate");
        var startTime = document.getElementById("startTime");

        startDate = JSON.stringify(startDate.value);
        startTime = JSON.stringify(startTime.value)

        var endDate = document.getElementById("endDate");
        var endTime = document.getElementById("endTime");

        endDate = JSON.stringify(endDate.value);
        endTime = JSON.stringify(endTime.value)

        var reason = document.getElementById("reason");
        var selection = document.getElementById("selection");

        reason = JSON.stringify(reason.value);
        var index = selection.selectedIndex
        var option = selection.options[index].value


        $.ajax({
            type: "post",
            url: "/subLeave",
            data:{"startDate":startDate,
                "startTime":startTime,
                "endDate":endDate,
                "endTime":endTime,
                "reason":reason,
                "option":option},
            dataType:"json",
            success:function (result){
                console.info(result.data)
                if(result.data){
                    console.info("即将跳转")
                    layer.msg("已提交请求，即将跳转",{icon:1,time:500},function () {
                        window.location = "/leave2"
                    })
                }
            }
        })

    }
</script>
</html>